-
Notifications
You must be signed in to change notification settings - Fork 1.6k
User/beenachauhan/wsladiag localization support #13997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User/beenachauhan/wsladiag localization support #13997
Conversation
ddebff2 to
1107c6a
Compare
benhillis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we will want to add WSLA strings to a different .resw file. Otherwise we will have localized strings in both products that do not need to be present.
We might be able to get away with it either by relying on the fact that the localization methods are inline, and so the compiler should eliminate the strings that aren't used, or by having a special prefix for WSLA strings so the localization script can generate two separate headers. Either way, that's something that would be ok to do in a followup PR IMO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds comprehensive localization support to the wsladiag diagnostics tool by replacing all hardcoded user-facing strings with localized messages from Resources.resw. The changes ensure that error messages, usage information, and session listing output can be properly localized for international users.
Key Changes
- Replaced hardcoded strings with 11 new localization entries for wsladiag-specific messages
- Refactored usage information to use
PrintUsage()function with localized message - Updated error handling to use consistent localization API patterns
- Improved table formatting to properly handle localized column headers with dynamic width calculation
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/windows/wsladiag/wsladiag.cpp | Replaced all hardcoded user-facing strings with Localization API calls; added using declarations; renamed variable from 'code' to 'exitCode' for clarity; changed ErrorCodeToString to GetErrorString; improved table formatting logic |
| localization/strings/en-US/Resources.resw | Added 11 new message entries (MessageWsladiagUsage, MessageWslaSessionNotFound, MessageWslaOpenSessionFailed, MessageWslaNoSessionsFound, MessageWslaSessionsFound, MessageWslaShellExited, MessageWslaShellSignalled, MessageWslaHeaderId, MessageWslaHeaderCreatorPid, MessageWslaHeaderDisplayName, MessageWslaUnknownCommand) with appropriate localization annotations |
src/windows/wsladiag/wsladiag.cpp
Outdated
| wslutil::PrintMessage(std::format(L"Found {} WSLA session{}:", sessions.size(), sessions.size() > 1 ? L"s" : L""), stdout); | ||
| wslutil::PrintMessage(Localization::MessageWslaSessionsFound(sessions.size()), stdout); | ||
|
|
||
| // Compute column widths from headers + data . |
Copilot
AI
Jan 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an extra space before the period in this comment. It should be "headers + data." instead of "headers + data ."
| // Compute column widths from headers + data . | |
| // Compute column widths from headers + data. |
46dfad2 to
57c5c1d
Compare
Ah all of the languages strings are embedded in the binaries themselves? Then yeah, this is probably ok. |
57c5c1d to
89db2ad
Compare
OneBlue
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ! Thank you for doing this.
benhillis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think copilot identified something real
89db2ad to
846648e
Compare
Thanks for the heads-up! If you can point me to what Copilot flagged, I’ll take a look. |
|
@beena352 there are comments in this PR with copilots findings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
src/windows/wsladiag/wsladiag.cpp
Outdated
|
|
||
| using namespace wsl::shared; | ||
| namespace wslutil = wsl::windows::common::wslutil; | ||
| using wsl::shared::Localization; |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The using wsl::shared::Localization; declaration is redundant since using namespace wsl::shared; on line 24 already brings the Localization class into scope. This can be removed for clarity.
| using wsl::shared::Localization; |
src/windows/wsladiag/wsladiag.cpp
Outdated
| using wsl::windows::common::Context; | ||
| using wsl::windows::common::ExecutionContext; |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The using declarations for Context and ExecutionContext are added but these types do not appear to be used anywhere in this file. These should be removed unless they are actually needed.
| using wsl::windows::common::Context; | |
| using wsl::windows::common::ExecutionContext; |
| <value>No WSLA sessions found.</value> | ||
| </data> | ||
| <data name="MessageWslaSessionsFound" xml:space="preserve"> | ||
| <value>Found {} WSLA session(s):</value> |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The localized message always includes "(s)" regardless of the count, which changes the output behavior from the original code. The original code conditionally added "s" only when sessions.size() > 1, producing "Found 1 WSLA session:" or "Found 2 WSLA sessions:". The new version will always show "Found 1 WSLA session(s):" which is less grammatically natural. Consider using the conditional plural pattern to maintain the original behavior, or verify that this change is intentional.
| <value>Found {} WSLA session(s):</value> | |
| <value>Found {} WSLA session{}:</value> |
846648e to
f08bf3a
Compare
f08bf3a to
ec16460
Compare
Thanks! I picked up the Copilot suggestions that fit the current scope. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| <data name="MessageWslaSessionNotFound" xml:space="preserve"> | ||
| <value>Session not found: '{}'</value> | ||
| <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment> | ||
| </data> | ||
| <data name="MessageWslaOpenSessionFailed" xml:space="preserve"> | ||
| <value>OpenSessionByName('{}') failed</value> | ||
| <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment> | ||
| </data> | ||
| <data name="MessageWslaNoSessionsFound" xml:space="preserve"> | ||
| <value>No WSLA sessions found.</value> | ||
| </data> | ||
| <data name="MessageWslaSessionsFound" xml:space="preserve"> | ||
| <value>Found {} WSLA session{}:</value> | ||
| <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment> | ||
| </data> | ||
| <data name="MessageWslaShellExited" xml:space="preserve"> | ||
| <value>{} exited with: {}</value> | ||
| <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment> | ||
| </data> | ||
| <data name="MessageWslaShellSignalled" xml:space="preserve"> | ||
| <value> (signalled)</value> | ||
| </data> | ||
| <data name="MessageWslaHeaderId" xml:space="preserve"> | ||
| <value>ID</value> | ||
| </data> | ||
| <data name="MessageWslaHeaderCreatorPid" xml:space="preserve"> | ||
| <value>Creator PID</value> | ||
| </data> | ||
| <data name="MessageWslaHeaderDisplayName" xml:space="preserve"> | ||
| <value>Display Name</value> | ||
| </data> | ||
| <data name="MessageWslaUnknownCommand" xml:space="preserve"> | ||
| <value>Unknown command: '{}'</value> | ||
| <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment> | ||
| </data> |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation: The data elements starting from line 1882 onwards are missing the standard 2-space indentation used throughout the rest of the file. All data tags should be indented with 2 spaces to match the existing formatting convention.
| <data name="MessageWslaSessionNotFound" xml:space="preserve"> | |
| <value>Session not found: '{}'</value> | |
| <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment> | |
| </data> | |
| <data name="MessageWslaOpenSessionFailed" xml:space="preserve"> | |
| <value>OpenSessionByName('{}') failed</value> | |
| <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment> | |
| </data> | |
| <data name="MessageWslaNoSessionsFound" xml:space="preserve"> | |
| <value>No WSLA sessions found.</value> | |
| </data> | |
| <data name="MessageWslaSessionsFound" xml:space="preserve"> | |
| <value>Found {} WSLA session{}:</value> | |
| <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment> | |
| </data> | |
| <data name="MessageWslaShellExited" xml:space="preserve"> | |
| <value>{} exited with: {}</value> | |
| <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment> | |
| </data> | |
| <data name="MessageWslaShellSignalled" xml:space="preserve"> | |
| <value> (signalled)</value> | |
| </data> | |
| <data name="MessageWslaHeaderId" xml:space="preserve"> | |
| <value>ID</value> | |
| </data> | |
| <data name="MessageWslaHeaderCreatorPid" xml:space="preserve"> | |
| <value>Creator PID</value> | |
| </data> | |
| <data name="MessageWslaHeaderDisplayName" xml:space="preserve"> | |
| <value>Display Name</value> | |
| </data> | |
| <data name="MessageWslaUnknownCommand" xml:space="preserve"> | |
| <value>Unknown command: '{}'</value> | |
| <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment> | |
| </data> | |
| <data name="MessageWslaSessionNotFound" xml:space="preserve"> | |
| <value>Session not found: '{}'</value> | |
| <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment> | |
| </data> | |
| <data name="MessageWslaOpenSessionFailed" xml:space="preserve"> | |
| <value>OpenSessionByName('{}') failed</value> | |
| <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment> | |
| </data> | |
| <data name="MessageWslaNoSessionsFound" xml:space="preserve"> | |
| <value>No WSLA sessions found.</value> | |
| </data> | |
| <data name="MessageWslaSessionsFound" xml:space="preserve"> | |
| <value>Found {} WSLA session{}:</value> | |
| <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment> | |
| </data> | |
| <data name="MessageWslaShellExited" xml:space="preserve"> | |
| <value>{} exited with: {}</value> | |
| <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment> | |
| </data> | |
| <data name="MessageWslaShellSignalled" xml:space="preserve"> | |
| <value> (signalled)</value> | |
| </data> | |
| <data name="MessageWslaHeaderId" xml:space="preserve"> | |
| <value>ID</value> | |
| </data> | |
| <data name="MessageWslaHeaderCreatorPid" xml:space="preserve"> | |
| <value>Creator PID</value> | |
| </data> | |
| <data name="MessageWslaHeaderDisplayName" xml:space="preserve"> | |
| <value>Display Name</value> | |
| </data> | |
| <data name="MessageWslaUnknownCommand" xml:space="preserve"> | |
| <value>Unknown command: '{}'</value> | |
| <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment> | |
| </data> |
Summary of the Pull Request
Adds localization support to wsladiag by replacing all hardcoded user-facing strings with localized messages from Resources.resw. All messages (usage, errors, session list output) are now accessible via the Localization class.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Usage information
Validation Steps Performed
Built project successfully with cmake --build build-vs-x64 --config Debug --parallel
Ran all wsladiag tests: [bin\x64\debug\test.bat /name:WsladiagTests]- All 8 tests passed
Manually tested commands:
[wsladiag.exe --help] - displays localized usage
wsladiag.exe list - displays localized session list or "No WSLA sessions found"
wsladiag.exe shell InvalidSession - displays localized error "Session not found: 'InvalidSession'"
wsladiag.exe badcommand - displays localized "Unknown command: 'badcommand'" error